<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% String contextPath = request.getContextPath(); %>
<% String msg= (String)request.getAttribute("msg"); %>
<meta http-equiv="content-script-type" content="text/javascript">
<%@ page import="common.*"%>
<%@ page import="java.util.*" %>
<%
	String strStart = request.getParameter("start");
	if(strStart == null || strStart.length() == 0) strStart = "0";
	int start = Integer.parseInt(strStart);
	List<Order> orderlist = Order.find_not_yet(start);
	List<String> order_num_list = Order.find_not_yet_order(start);
	List<Order> maxOrder = Order.find_not_yet();
	int k=0;
	int j=0;
	int max = (maxOrder.size());
	boolean show = false;
%>
<link href="<%= contextPath %>/css/order.css" rel="stylesheet" type="text/css">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style type="text/css">  
	<!-- 
		div.hidden {
			display: none;
		}
	-->  
	</style>  
	<script type="text/javascript">
		function showButton(id) {
			var e=document.getElementById(id);
			e.className="";
		}
	</script>
	<title>出荷管理</title>

</head>
	<body>
		
		<div id="deli">
		<%if(msg!=null){%>
			<h2><%=msg %></h2>
		<% } %>
		<%if(msg==null){%>
		<%if(orderlist.size()==0){%>
			<h2>現在未発信の配送データはありません。</h2>
		<% }}%>
		<%if(orderlist.size()!=0){ %>
			
			
			<div id="delitable">
				<table border="1">
					<tr>
						<th>受注番号</th>
						<th>顧客コード</th>
						<th>商品コード</th>
						<th>注文数</th>
					</tr>
				
		<%} %>
					<% for(k=0;k<orderlist.size();k++){
						 Order order = orderlist.get(k);//後で変更
						 if(Receipt_Select.Receipt_Select(order.getNum())){
					%>
						 
				
					<tr>
						<td><%=order.getNum() %></td>
						<td><%=order.getCustomer_code() %></td>
						<td><%=order.getItem_code() %></td>
						<td><%=order.getOrders() %></td>
					</tr>
							<% show=true;%>
							<% }%>
					<% }%>
				<%if(show==false){ %>
					<tr>
						<td colspan="4">送信できる配送データが無いです。</td>
						
					</tr>
				<% }%>
				</table>
			</div>
				<%if(show){ %>
					<%
					int s = 0;
						while(s < max ) 
						{
							out.println("<a href='deli.jsp?start=" + s +"'>");
							out.print(1+ s/10);
							out.println("</a>&nbsp;");
							s += 10;
						}
					%>
				
			
					<% if(orderlist.size() > 0){ %>
						<br />
						<br />
						<span>
							<a onClick="showButton('deliver');window.open('<%=request.getContextPath() %>/orderOpe/ReceiptServlet?<% for(j=0;j<order_num_list.size();j++){ if(Receipt_Select.Receipt_Select(order_num_list.get(j))){%>order_num=<%=order_num_list.get(j)%><% if((j+1)<order_num_list.size()){ %>&<%} %><%} %><%} %>','','width=400,height=500');return false;">
								<input type="button" value="印刷">
							</a>
						</span>
					<% }%>
			<% }%>
			<div ID="deliver" class="hidden">
				<a href="<%=request.getContextPath() %>/shukka/DeliServlet" >
					<input type="button" value="出荷指示">
				</a>
			</div>
			<form action="<%=request.getContextPath() %>/operator/menu.jsp">
				<input type="submit" value="担当者メニューへ戻る"/>
			</form>
		</div>
		
	</body>
<script type="text/javascript">
</script>
</html>